package com.penghaisoft.microwms.product.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.penghaisoft.microwms.common.dto.Resp;
import com.penghaisoft.microwms.common.page.Pager;
import com.penghaisoft.microwms.common.service.BaseService;
import com.penghaisoft.microwms.common.wms.model.ProContractChange;
import com.penghaisoft.microwms.product.dao.ProContractChangeMapper;
import com.penghaisoft.microwms.product.service.IProContractChangeService;

/**
 * @Description: TODO
 * @param
 * @author lengxf
 * @date 2018年9月17日 上午11:06:30
 */
@Service("proContractChangeService")
public class ProContractChangeServiceImpl extends BaseService implements IProContractChangeService {
	@Resource
	private ProContractChangeMapper proContractChangeMapper;

	/**
	 * 新增记录
	 * 
	 * @param baseResource
	 * @return
	 */
	@Override
	public Resp create(ProContractChange proContractChange) {
		proContractChangeMapper.create(proContractChange);
		return success();
	}

	/**
	 * 删除记录（逻辑删除）
	 * 
	 * @param baseResource
	 * @return
	 */
	@Override
	public Resp delete(ProContractChange proContractChange) {
		proContractChangeMapper.delete(proContractChange);
		return success();
	}

	/**
	 * 查询列表
	 * 
	 * @param pager
	 * @param baseResource
	 * @return
	 */
	@Override
	public Pager<ProContractChange> findListByCondition(int page, int rows, ProContractChange condition) {
		Pager<ProContractChange> pager = new Pager<>();
		pager.setPage(page);
		pager.setRows(rows);
		condition.preQuery();
		List<ProContractChange> records = proContractChangeMapper.queryList(pager, condition);
		long size = proContractChangeMapper.queryCount(condition);
		pager.setRecords(records);
		pager.setTotalCount(size);
		return pager;
	}

	/**
	 * 查询列表
	 * 
	 * @param pager
	 * @param baseResource
	 * @return
	 */
	@Override
	public List<ProContractChange> findListByConditionList(ProContractChange condition) {
		return proContractChangeMapper.queryList(null, condition);
	}

	/**
	 * 查询单条
	 * 
	 * @param id
	 * @return
	 */
	@Override
	public ProContractChange findById(String id) {
		return proContractChangeMapper.queryById(id);
	}

	/**
	 * 修改记录
	 * 
	 * @param baseResource
	 * @return
	 */
	@Override
	public Resp update(ProContractChange proContractChange) {
		proContractChangeMapper.updateBySelect(proContractChange);
		return success();
	}

}
